* intervals.c (set_point): Check for point out of bounds before
authorJim Blandy <jimb@redhat.com>
Fri, 14 May 1993 14:40:56 +0000 (14:40 +0000)
committerJim Blandy <jimb@redhat.com>
Fri, 14 May 1993 14:40:56 +0000 (14:40 +0000)
checking for an empty interval tree.

src/intervals.c

index 5f4998789ad2fab734ebdedf8371f5177ee9644c..f08d80cff0730c43a82de7ecaf3c85fe015f8691 100644 (file)
@@ -1254,16 +1254,18 @@ set_point (position, buffer)
   if (position == buffer->text.pt)
     return;
 
+  /* Check this now, before checking if the buffer has any intervals.
+     That way, we can catch conditions which break this sanity check
+     whether or not there are intervals in the buffer.  */
+  if (position > BUF_Z (buffer) || position < BUF_BEG (buffer))
+    abort ();
+
   if (NULL_INTERVAL_P (buffer->intervals))
     {
       buffer->text.pt = position;
       return;
     }
 
-  /* Perhaps we should just change `position' to the limit. */
-  if (position > BUF_Z (buffer) || position < BUF_BEG (buffer))
-    abort ();
-
   /* Position Z is really one past the last char in the buffer.  */
   if (position == BUF_ZV (buffer))
     iposition = position - 1;